﻿using System;
using System.IO;

//文件的写入
namespace FileApplication3 {
    class Program {
        static void Main(string[] args) {

            string[] names = new string[] { "Zara Ali", "Nuha Ali" };
            //会生成一个名称为 names.txt 的文件，在工作目录中
            using (StreamWriter sw = new StreamWriter("names.txt")) {
                foreach (string s in names) {
                    sw.WriteLine(s);

                }
            }

            // 从文件中读取并显示每行
            string line = "";
            using (StreamReader sr = new StreamReader("names.txt")) {
                while ((line = sr.ReadLine()) != null) {
                    Console.WriteLine(line);
                }
            }
            Console.ReadKey();
        }
    }
}
